package com.sgcc.fj.pmos.mobileapp.app;

import android.app.Application;
import android.content.Context;

import androidx.annotation.CallSuper;
import androidx.multidex.MultiDex;

import com.sgcc.fj.pmos.mobileapp.utils.CrashHandlers;


public class BaseApplication extends Application {

    /**
     * 是否真实校验短信验证码
     * true 跳过短信验证码  false 不跳过短信验证码
     */
    public static boolean isSkipSMSAuth = true;

    @Override
    public void onCreate() {
        super.onCreate();
        //崩溃日志保存本地
        CrashHandlers.getInstance().init(this);
        beforeUserAgreement();
        if (!isUserAgreement())
            return;
        afterUserAgreement();
    }

    /**
     * 用户同意用户之前调用，只做最基本的初始化，不能涉及任何敏感内容
     */
    private void beforeUserAgreement() {
        BaseAppIniter.initBeforeUserAgreement(this);
    }

    /**
     * 用户同意用户之后调用
     */
    public void afterUserAgreement() {
        BaseAppIniter.initAfterUserAgreement(this);
    }

    /**
     * 用户是否同意了隐私协议
     *
     * @return
     */
    protected boolean isUserAgreement() {
        return BaseAppIniter.isUserAgreement();
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

    @CallSuper
    @Override
    public void onTerminate() {
        super.onTerminate();
        BaseAppIniter.destroy();
    }

}
